/*
	文件说明：
	#define 等宏定义在h文件里面的好处，可以防止头文件在各个c文件里面重复包含
	头文件里面对外封装，也更好的修改最底层的参数。
	
	吸取教训，在用#define宏定义的时候，千万不要在后面加“;”
	编译不带不会检查到报错，反而认为程序正常，导致程序运行不了
**/

#ifndef __LCD_H
#define __LCD_H

#include "stm32f10x.h"                  // Device header
#include "MySPI.h"
#include "GPIO.h"
//#include "stm32_Delay.h"

#define u8  unsigned char 
#define u16 unsigned int 

/////////////////////////////////////用户配置区///////////////////////////////////	 
//支持横竖屏快速定义切换
#define USE_HORIZONTAL  		0	//定义是否使用横屏 		0,不使用.1,使用.

//-----------------------------SPI 总线配置--------------------------------------//
#define USE_HARDWARE_SPI     0  //1:Enable Hardware SPI;0:USE Soft SPI

//-------------------------屏幕物理像素设置--------------------------------------//
#define LCD_X_SIZE	        240
#define LCD_Y_SIZE	        320

#if USE_HORIZONTAL//如果定义了横屏 
#define X_MAX_PIXEL	        LCD_Y_SIZE
#define Y_MAX_PIXEL	        LCD_X_SIZE
#else
#define X_MAX_PIXEL	        LCD_X_SIZE
#define Y_MAX_PIXEL	        LCD_Y_SIZE
#endif
//////////////////////////////////////////////////////////////////////////////////
	 

#define RED  	0xf800
#define GREEN	0x07e0
#define BLUE 	0x001f
#define WHITE	0xffff
#define BLACK	0x0000
#define YELLOW  0xFFE0
#define GRAY0   0xEF7D   		//灰色0 3165 00110 001011 00101
#define GRAY1   0x8410      	//灰色1 00000 000000 00000
#define GRAY2   0x4208      	//灰色2	1111111111011111

//define LCD PIN
#define	LCD_CS_SET  GPIO_WriteBit(GPIO_X, SPI_CS, Bit_SET)		
#define	LCD_CS_CLR  GPIO_WriteBit(GPIO_X, SPI_CS, Bit_RESET)

#define	LCD_RS_SET  GPIO_WriteBit(GPIO_X, DC, Bit_SET)
#define	LCD_RS_CLR  GPIO_WriteBit(GPIO_X, DC, Bit_RESET)

#define	LCD_SDA_SET  GPIO_WriteBit(GPIO_X, SPI_MOSI, Bit_SET)
#define	LCD_SDA_CLR  GPIO_WriteBit(GPIO_X, SPI_MOSI, Bit_RESET)

#define	LCD_SCL_SET  GPIO_WriteBit(GPIO_X, SPI_SCK, Bit_SET)
#define	LCD_SCL_CLR  GPIO_WriteBit(GPIO_X, SPI_SCK, Bit_RESET)

#define	LCD_RST_SET  GPIO_WriteBit(GPIO_X, RESET, Bit_SET)
#define	LCD_RST_CLR  GPIO_WriteBit(GPIO_X, RESET, Bit_RESET)

#define	LCD_LED_SET  GPIO_WriteBit(GPIO_X, LED, Bit_SET)
#define	LCD_LED_CLR  GPIO_WriteBit(GPIO_X, LED, Bit_RESET)


void Lcd_Reset(void);
void Lcd_WriteIndex(u8 Index);
void Lcd_WriteData(u8 Data);
void Lcd_WriteReg(u8 Index,u8 Data);
u16 Lcd_ReadReg(u8 LCD_Reg);
void Lcd_Reset(void);
void Lcd_Init(void);
void Lcd_Clear(u16 Color);
void Lcd_SetXY(u16 x,u16 y);
void Gui_DrawPoint(u16 x,u16 y,u16 Data);
unsigned int Lcd_ReadPoint(u16 x,u16 y);
void Lcd_SetRegion(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd);
void Lcd_WriteData_16Bit(u16 Data);

#endif
